Add a phased classical action for SelectedMajoranaFermion#1778
Open
maxglick wants to merge 13 commits intoquantumlib:mainfrom
Open
Add a phased classical action for SelectedMajoranaFermion#1778maxglick wants to merge 13 commits intoquantumlib:mainfrom
maxglick wants to merge 13 commits intoquantumlib:mainfrom
Conversation
Merge with upstream.
mpharrigan
reviewed
Jan 6, 2026
Comment on lines
+144
to
+145
| if len(self.control_registers) > 1 or len(self.selection_registers) > 1: | ||
| return NotImplemented |
Collaborator
There was a problem hiding this comment.
is this restriction necessary?
Contributor
Author
There was a problem hiding this comment.
I'm not sure - it is hard for me to understand what this gate does in the general case. Is my understanding in #1699 (comment) correct?
Comment on lines
142
to
143
| if self.target_gate != cirq.X: | ||
| return NotImplemented |
Collaborator
There was a problem hiding this comment.
In combination with basis_state_phase, this should be able to support Z as well. Z imparts a phase (and leaves the computational basis states unaffected)
Contributor
Author
There was a problem hiding this comment.
I have now added Z.
Comment on lines
+152
to
+153
| max_selection = self.selection_registers[0].dtype.iteration_length_or_zero() - 1 | ||
| target = (2 ** (max_selection - selection)) ^ target |
Collaborator
There was a problem hiding this comment.
can you add a comment describing how this logic works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a phased classical action for SelectedMajoranaFermion.
The classical action only exists for some choices of
target_gate, and we assume specificallytarget_gate=cirq.X(and also that there is only 1 control register and 1 selection register).Fixes #1699